<?php

namespace IDock\Insurance\QHIC\Request;

use Exception;
use IDock\Insurance\QHIC\Request\AllQHICRequest;
use IDock\Insurance\QHIC\Response\ProposalRecallResponse;
use IDock\Insurance\QHIC\Response\UnderwritingRecallResponse;
use IDock\Visitor\ProposalRecallVisitor;

class UnderwritingRecallRequest extends AllQHICRequest
{
    protected $requestType = 'VHL0014';

    protected $response = UnderwritingRecallResponse::class;

    protected $urlTip = '取消订单';

    /**
     * @var ProposalRecallVisitor $visitor
     */
    protected $visitor;

    /**
     * @return array
     * @throws Exception
     */
    public function generate(): array
    {
        $param = [
            'AppNoList' => [],
        ];
        if(!empty($this->visitor->ciInquiryNo)){
            $param['AppNoList'][] = $this->visitor->ciInquiryNo;
        }
        if(!empty($this->visitor->biInquiryNo)){
            $param['AppNoList'][] = $this->visitor->biInquiryNo;
        }
        if(empty($param['AppNoList'])){
            throw new Exception("询价单号不能为空");
        }
        return $param;
    }
}
